package com.example.spingbook.service;

import com.example.spingbook.dao.BookDao;
import com.example.spingbook.model.BookInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookService {
    @Autowired
    private BookDao bookDao;

    public List<BookInfo> getList(){

//        BookDao bookDao = new BookDao();

        //从数据库中查询，先mock数据
        List<BookInfo> bookInfos = bookDao.mockData();

        for(BookInfo bookInfo : bookInfos){
            if(bookInfo.getStatus() == 1){
                bookInfo.setStatusCN("可借阅");
            }else{
                bookInfo.setStatusCN("不可借阅");
            }
        }
        return bookInfos;
    }
}
